/* $Header: kbd_tbls.c,v 2.2 01/10/02 10:29:19 przybyls Exp $ */

/* kbd_tbls.c - workfile get/set for keyboard and display setpoints */
/* Bob Cook; Feb 1993 */
/* Copyright (c) 1993, Hewlett-Packard Co. */




#include  <typedefs.h>
#include  <error.h>
#include  <config.h>
#include  <method.h>
#include  <stddef.h>


#include <kbd_ui.h>
#include <beep.h>


/********************* wrapper function prototypes *********************/
/*
 * Format:
 *    Get commands:
 *        mGetWrapperCommand(void *parameter, U_INT8 number)
 *    Set commands:
 *        mSetWrapperCommand(void *parameter, INT32 setpoint, U_INT8 number)
 *    Examples:
 *       parameter - pointer to oven, detector or inlet zones
 *       setpoint - value of setpoint from received command
 *       number - as ramp number
 */

static INT32   mGetSequenceLock(void *parm, U_INT8 num);
static INT32   mGetClockTableLock(void *parm, U_INT8 num);
static INT32   mGetClockTableExecLock(void *parm, U_INT8 num);
static INT32   mGetMethSeqClkTblLock(void *parm, U_INT8 num);
static INT32   mGetDataCommKeyboardLock(void *parm, U_INT8 num);
static INT32   mGetDataCommStartLock(void *parm, U_INT8 num);
static INT32   mGetRemoteStartLock(void *parm, U_INT8 num);
static INT32   mGetKeyClick(void *parm, U_INT8 num);
static INT32   mGetWarningBeep(void *parm, U_INT8 num);
static INT32   mGetSetpointModifiedBeep(void *parm, U_INT8 num);
static INT32   mGetLanguage(void *parm, U_INT8 num);
static INT32   mGetRadix(void *parm, U_INT8 num);



static UI_ERR  mSetClearSequenceLock(void *parm, INT32 setpt, U_INT8 num);
static UI_ERR  mSetClearClockTableLock(void *parm, INT32 setpt, U_INT8 num);
static UI_ERR  mSetClearClockTableExecLock(void *parm,INT32 setpt, U_INT8 num);
static UI_ERR  mSetClearMethSeqClkTblLock(void *parm,INT32 setpt, U_INT8 num);
static UI_ERR  mSetClearDataCommKeyboardLock(void *parm,INT32 setpt,U_INT8 num);
static UI_ERR  mSetClearDataCommStartLock(void *parm,INT32 setpt,U_INT8 num);
static UI_ERR  mSetClearRemoteStartLock(void *parm,INT32 setpt,U_INT8 num);
static UI_ERR  mSetKeyClick(void *parm,INT32 setpt,U_INT8 num);
static UI_ERR  mSetWarningBeep(void *parm,INT32 setpt,U_INT8 num);
static UI_ERR  mSetSetpointModifiedBeep(void *parm,INT32 setpt,U_INT8 num);
static UI_ERR  mSetLanguage(void *parm, INT32 setpt, U_INT8 num);
static UI_ERR  mSetRadix(void *parm, INT32 setpt, U_INT8 num);



static UI_ERR DummyFunction(void *which);

/********************* command table entries *********************/
/*
 * Format:
 *   static const METHCMD_ENTRY mmCommandTableEntries[] =
 *   {
 *     {mGetWrapperCommand, mSetWrapperCommand, number, type of setpoint}
 *   }
 */

static const METHCMD_ENTRY mmGCKC[] =
{
        {mGetSequenceLock, mSetClearSequenceLock, 0, METH_ON_OFF},
        {mGetDataCommKeyboardLock,mSetClearDataCommKeyboardLock,0,METH_ON_OFF},
        {mGetDataCommStartLock,mSetClearDataCommStartLock,0,METH_ON_OFF},
        {mGetRemoteStartLock,mSetClearRemoteStartLock,0,METH_ON_OFF},
        {mGetClockTableLock, mSetClearClockTableLock, 0, METH_ON_OFF},
        {mGetClockTableExecLock, mSetClearClockTableExecLock, 0, METH_ON_OFF},
        {mGetMethSeqClkTblLock, mSetClearMethSeqClkTblLock, 0, METH_ON_OFF},
        {mGetKeyClick,mSetKeyClick,0,METH_ON_OFF},
        {mGetWarningBeep,mSetWarningBeep,0,METH_ON_OFF},
        {mGetSetpointModifiedBeep,mSetSetpointModifiedBeep,0,METH_ON_OFF},
        {mGetLanguage, mSetLanguage, 0, METH_INT0},
        {mGetRadix, mSetRadix, 0, METH_INT0},
};




/********************* command tables *********************/
/*
 * Format:
 *   const METHCMD mCommandTable[] =
 *   {
 *      MAXINDEX(mmCommandTableEntries, METHCMD_ENTRY),
 *      &mmCommandTableEntries[starting_index_in_table],
 *      parameter,
 *      PreCommandFunction,
 *      PostCommandFunction
 *   }
 */

const METHCMD mGCKC =
{
        MAXINDEX(mmGCKC, METHCMD_ENTRY),
        &mmGCKC[0],
        (void *)NULL,
        DummyFunction,
        DummyFunction
};




/********************* "get" wrapper functions *********************/

static UI_ERR DummyFunction(void *which)
{
        (void) which;
        return OK;
}


static INT32   mGetSequenceLock(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetSequenceLock() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}


static INT32   mGetClockTableLock(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetClockTableLock() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}

static INT32   mGetClockTableExecLock(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetClockTableSeqLock() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}

static INT32   mGetMethSeqClkTblLock(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetLSMSeqLock() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}


static INT32   mGetDataCommKeyboardLock(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetDataCommKeyboardLock() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}

static INT32   mGetDataCommStartLock(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetStartRunLock() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}

static INT32   mGetRemoteStartLock(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetRemoteStartLock() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}

static INT32   mGetKeyClick(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetKeyClickEnabled() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}

static INT32   mGetWarningBeep(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetWarningBeepEnabled() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}

static INT32   mGetSetpointModifiedBeep(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        if( GetSetptBeepEnabled() == TRUE )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}


static INT32   mGetLanguage(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return (INT32)GetLanguage();
}

static INT32   mGetRadix(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   if( GetRadix() == '.' )
   {
      return 0;
   }
   else
   {
      return 1;
   }
}



/********************* "set" wrapper functions *********************/


static UI_ERR  mSetClearSequenceLock(void *parm, INT32 setpt, U_INT8 num)
{
   (void) parm;
   (void) num;
   if ((ON_OFF) setpt == ON)
   {
      SetSequenceLock();
      return OK;
   }
   else if ((ON_OFF) setpt == OFF)
   {
      ClearSequenceLock();
      return OK;
   }
   else
   {
      return INVALID_PARAM;
   }
}

static UI_ERR  mSetClearClockTableLock(void *parm, INT32 setpt, U_INT8 num)
{
   (void) parm;
   (void) num;
   if ((ON_OFF) setpt == ON)
   {
      SetClockTableLock();
      return OK;
   }
   else if ((ON_OFF) setpt == OFF)
   {
      ClearClockTableLock();
      return OK;
   }
   else
   {
      return INVALID_PARAM;
   }
}

static UI_ERR  mSetClearClockTableExecLock(void *parm, INT32 setpt, U_INT8 num)
{
   (void) parm;
   (void) num;
   if ((ON_OFF) setpt == ON)
   {
      SetClockTableSeqLock();
      return OK;
   }
   else if ((ON_OFF) setpt == OFF)
   {
      ClearClockTableSeqLock();
      return OK;
   }
   else
   {
      return INVALID_PARAM;
   }
}

static UI_ERR  mSetClearMethSeqClkTblLock(void *parm, INT32 setpt, U_INT8 num)
{
   (void) parm;
   (void) num;
   if ((ON_OFF) setpt == ON)
   {
      SetLSMSeqLock();
      return OK;
   }
   else if ((ON_OFF) setpt == OFF)
   {
      ClearLSMSeqLock();
      return OK;
   }
   else
   {
      return INVALID_PARAM;
   }
}

static UI_ERR  mSetClearDataCommKeyboardLock(void *parm,INT32 setpt,U_INT8 num)
{
   (void) parm;
   (void) num;
   if ((ON_OFF) setpt == ON)
   {
      SetDataCommKeyboardLock();
      return OK;
   }
   else if ((ON_OFF) setpt == OFF)
   {
      ClearDataCommKeyboardLock();
      return OK;
   }
   else
   {
      return INVALID_PARAM;
   }
}

static UI_ERR  mSetClearDataCommStartLock(void *parm,INT32 setpt,U_INT8 num)
{
   (void) parm;
   (void) num;
   if ((ON_OFF) setpt == ON)
   {
      SetStartRunLock();
      return OK;
   }
   else if ((ON_OFF) setpt == OFF)
   {
      ClearStartRunLock();
      return OK;
   }
   else
   {
      return INVALID_PARAM;
   }
}

static UI_ERR  mSetClearRemoteStartLock(void *parm,INT32 setpt,U_INT8 num)
{
   (void) parm;
   (void) num;
   if ((ON_OFF) setpt == ON)
   {
      SetRemoteStartLock();
      return OK;
   }
   else if ((ON_OFF) setpt == OFF)
   {
      ClearRemoteStartLock();
      return OK;
   }
   else
   {
      return INVALID_PARAM;
   }
}


static UI_ERR   mSetKeyClick(void *parm,INT32 setpt,U_INT8 num)
{
   (void) parm;
   (void) num;
   switch (setpt)
   {
   case 0:
      SetKeyClickEnabled(FALSE);
      return OK;
   case 1:
      SetKeyClickEnabled(TRUE);
      return OK;
   default:
      return INVALID_PARAM;
   }

}


static UI_ERR   mSetWarningBeep(void *parm,INT32 setpt,U_INT8 num)
{
   (void) parm;
   (void) num;
   switch (setpt)
   {
   case 0:
      SetWarningBeepEnabled(FALSE);
      return OK;
   case 1:
      SetWarningBeepEnabled(TRUE);
      return OK;
   default:
      return INVALID_PARAM;
   }
}

static UI_ERR   mSetSetpointModifiedBeep(void *parm,INT32 setpt,U_INT8 num)
{
   (void) parm;
   (void) num;
   switch (setpt)
   {
   case 0:
      SetSetptBeepEnabled(FALSE);
      return OK;
   case 1:
      SetSetptBeepEnabled(TRUE);
      return OK;
   default:
      return INVALID_PARAM;
   }
}

static UI_ERR  mSetLanguage(void *parm, INT32 setpt, U_INT8 num)
{
   (void) parm;
   (void) num;
   return SetLanguage( (LANGUAGE)setpt );
}

static UI_ERR  mSetRadix(void *parm, INT32 setpt, U_INT8 num)
{
   (void) parm;
   (void) num;
   switch (setpt)
   {
   case 0:
      return SetRadix( (BIT8)'.' );
   case 1:
      return SetRadix( (BIT8)',');
   default:
      return INVALID_PARAM;
   }
}
